public class PopulateGeoCodeController {
	public String Latitude{get;set;}
	public String Longitude{get;set;}
	private String recordId;
	
	public PopulateGeoCodeController(){
		recordId = ApexPages.currentPage().getParameters().get('recId');
	}
	
	public PageReference populateLatLong(){
		if(recordId.startsWith('a009')){
			Company__c record = [Select Id, Latitude__c, Longitude__c from Company__c where Id =: recordId];
			record.Latitude__c = Latitude;
			record.Longitude__c = Longitude;
			update record;
		}
		else{
			Branch__c record = [Select Id, Latitude__c, Longitude__c from Branch__c where Id =: recordId];
			record.Latitude__c = Latitude;
			record.Longitude__c = Longitude;
			update record;
		}
		PageReference pageRef = new PageReference('/'+recordId);
		pageRef.setRedirect(true);
		return pageRef;
	}

}